#include "widget.h"
#include "ui_widget.h"

#include "mylineedit.h"
#include <QDebug>
#include <QKeyEvent>


Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

//    auto *edit = new MyLineEdit(this);
//    edit->resize(280, 40);
//    edit->move(30, 30);

    this->l = new QLabel(this);
    l->resize(20, 20);
    l->move(this->x, this->y);
    l->setFrameShape(QFrame::Box);
}

void Widget::keyPressEvent(QKeyEvent* e)
{
    if(e->key() == Qt::Key_Up)
    {
        this->y -= 3;
    }
    else if (e->key() == Qt::Key_Down)
    {
        this->y += 3;
    }
    else if (e->key() == Qt::Key_Left)
    {
        this->x -= 3;
    }
    else if (e->key() == Qt::Key_Right)
    {
        this->x += 3;
    }
    l->move(this->x, this->y);
}

Widget::~Widget()
{
    delete ui;
}
